package repository.relsys.util.json.nodes;

import java.net.URI;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

import repository.relsys.domainmodel.general.Resource;
import repository.relsys.domainmodel.ltool.interfaces.Feature;
import repository.relsys.domainmodel.ltool.interfaces.LearningTool;
import repository.relsys.domainmodel.ltool.interfaces.MobileDevice;
import repository.relsys.domainmodel.ltool.interfaces.OperetingSystem;
import repository.relsys.domainmodel.ltool.interfaces.ToolAvailability;
import repository.relsys.domainmodel.ltool.interfaces.ToolCost;

public class LearningToolDescriptionNode implements DescriptionNode {

	private LearningTool ltool;

	public LearningToolDescriptionNode(LearningTool ltool) {
		this.ltool = ltool;
	}

	public String getTitle() {
		return ltool.getTitle();
	}

	@Override
	public String getDescription() {
		// TODO Auto-generated method stub
		return ltool.getGeneralInfo().getDescription();
	}

	@Override
	public String getLaunchedTime() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().getLaunchedTime();
	}

	@Override
	public String getToolAvailability() {
		// TODO Auto-generated method stub
		return ltool.getGeneralInfo().getToolAvailability().getTitle();
	}

	@Override
	public String getToolCost() {
		// TODO Auto-generated method stub
		return ltool.getGeneralInfo().getToolCost().getTitle();
	}

	@Override
	public URI getToolURl() {
		// TODO Auto-generated method stub
		return ltool.getGeneralInfo().getToolURL();
	}

	@Override
	public String getVersion() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().getVersion();
	}

	@Override
	public boolean isOpenSource() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().isOpenSource();
	}

	@Override
	public boolean registration() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().registration();
	}

	@Override
	public Collection<Feature> getFeatures() {
		// TODO Auto-generated method stub
		return ltool.getFeatures();
	}

	public LinkedList<String> getFeaturesTitle() {

		LinkedList<String> names = new LinkedList<String>();
		Collection<Feature> features = getFeatures();

		Iterator<Feature> iter = features.iterator();

		while (iter.hasNext()) {
			Feature t = (Feature) iter.next();
			names.add(t.getTitle());

		}

		return names;

	}

	public LinkedList<String> getMDTitle() {

		LinkedList<String> mobiledevices = new LinkedList<String>();
		Collection<MobileDevice> md = getsupportedMobileDevice();
		Iterator<MobileDevice> iter = md.iterator();

		while (iter.hasNext()) {
			MobileDevice t = (MobileDevice) iter.next();
			mobiledevices.add(t.getTitle());

		}

		return mobiledevices;

	}

	@Override
	public void setFeatures(Collection<Feature> features) {
		// TODO Auto-generated method stub
		ltool.setFeatures(features);
	}

	@Override
	public Collection<MobileDevice> getsupportedMobileDevice() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().getsupportedMobileDevice();
	}

	@Override
	public Collection<OperetingSystem> getsupportedOS() {
		// TODO Auto-generated method stub
		return ltool.getTechnicalInfo().getsupportedOS();
	}

	@Override
	public URI getToolImgURl() {
		return ltool.getToolImgURL();
	}

	@Override
	public LinkedList<String> getOSTitle() {

		LinkedList<String> operetingSystems = new LinkedList<String>();
		Collection<OperetingSystem> os = getsupportedOS();
		Iterator<OperetingSystem> iter = os.iterator();

		while (iter.hasNext()) {
			OperetingSystem t = (OperetingSystem) iter.next();
			operetingSystems.add(t.getTitle());

		}

		return operetingSystems;

	}

}
